<!-- 
 * @Author: guanpf 992093924@qq.om
 * @Date: 2023-09-16 20:36:14
 * @LastEditTime: 2023-10-14 14:17:10
 * @LastEditors: guanpf
 * @Description: 
 * @FilePath: /ZCGL_WX/src/views/main/asset/components/asset-rank.vue
 -->
<template>
  <!-- 活跃数 -->
  <div class="asset-rank statistic-item">
    <div class="title">
      <div class="common-title">资产前十榜</div>
    </div>
    <div class="rank-list">
      <div class="item" v-for="(item, index) in rankList" :key="index">
        <div class="asset-name">
          <span class="rank-index" :style="`color:${colors[index]}`">{{ index + 1 }}</span
          >{{ item.assetName }}
        </div>
        <div>{{ item.subtotal }}<span class="unit">件</span></div>
      </div>
    </div>
  </div>
</template>

<script>
import AssetApi from '@/api/asset';
const colors = [
  "#446abd",
  "#87c26e",
  "#febe57",
  "#f05b5d",
  "#61bad9",
  "#87c26e",
  "#febe57",
  "#f05b5d",
  "#61bad9",
];
export default {
  data() {
    return {
      colors: colors,
      rankList: [],
    };
  },
  mounted() {
    this.getRankList()
  },
  methods:{
    async getRankList(){
      const { data } = await AssetApi.statisicsTopName()
      this.rankList = data
    }
  }
};
</script>

<style lang="less" scoped>
.asset-rank {
  padding: 10px;
}
.rank-list {
  margin-top: 10px;
  padding: 0 20px;
  .item {
    display: flex;
    justify-content: space-between;
    height: 40px;
    line-height: 40px;

    > :nth-child(1) {
      margin-right: 10px;
      flex:1;
      /* 单行显示省略号 */
     overflow: hidden;
     text-overflow: ellipsis;
     white-space: nowrap;

      .rank-index {
        width: 20px;
        display: inline-block;
      }
    }
    > :nth-child(2) {
      font-size: 18px;
      .unit {
        font-size: 12px;
        color: #666;
        margin-left: 2px;
      }
    }
  }
}
</style>
